package com.siwei.mes.entity.system;

import cn.dev33.satoken.stp.StpUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;


/**
 * 设备校准记录表(CalibrationRecord)实体类
 *
 * @author dmwang
 * @since 2024-07-18 18:59:19
 */
@Data
@Accessors(chain = true)
@Table(name = "pk_calibration_record")
@ApiModel(value = "CalibrationRecord", description = "设备校准记录表")
public class CalibrationRecord implements Serializable {
    private static final long serialVersionUID = 513297519705213902L;
    @Id
    @ApiModelProperty(value = "设备校准记录表主键ID", name = "id")
    private Long id;
    /**
     * 设备主键id
     */
    @Column(name = "equipment_id")
    @ApiModelProperty(value = "设备主键id", name = "equipmentId")
    private Long equipmentId;
    /**
     * 报告编号
     */
    @Column(name = "report_no")
    @ApiModelProperty(value = "报告编号", name = "reportNo")
    private String reportNo;
    /**
     * 校准单位
     */
    @Column(name = "calibration_unit")
    @ApiModelProperty(value = "校准单位", name = "calibrationUnit")
    private String calibrationUnit;
    /**
     * 校准时间
     */
    @Column(name = "calibration_time")
    @ApiModelProperty(value = "校准时间", name = "calibrationTime")
    private Date calibrationTime;
    /**
     * 校准结果
     */
    @Column(name = "calibration_text")
    @ApiModelProperty(value = "校准结果", name = "calibrationText")
    private String calibrationText;
    /**
     * 校准附件
     */
    @Column(name = "calibration_annex")
    @ApiModelProperty(value = "校准附件", name = "calibrationAnnex")
    private String calibrationAnnex;
    /**
     * 创建人
     */
    @Column(name = "creater")
    @ApiModelProperty(value = "创建人", name = "creater")
    private Long creater;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间", name = "createTime")
    private Date createTime;
    /**
     * 修改人
     */
    @Column(name = "updater")
    @ApiModelProperty(value = "修改人", name = "updater")
    private Long updater;
    /**
     * 更新时间
     */
    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间", name = "updateTime")
    private Date updateTime;
    /**
     * 是否删除  1-删除
     */
    @Column(name = "is_del")
    @ApiModelProperty(value = "是否删除  1-删除", name = "isDel")
    private Integer isDel;

    @Transient
    @ApiModelProperty(value = "设备名称")
    private String equipmentName;

    public CalibrationRecord init(boolean isCreate) {
        this.setUpdater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null)
                .setUpdateTime(new Date());
        if (isCreate) {
            this.setCreater(StpUtil.isLogin() ? StpUtil.getLoginIdAsLong() : null)
                    .setCreateTime(new Date())
                    .setIsDel(0);
        }
        return this;
    }
}
